package base;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.mysql.jdbc.Statement;

import bean.Medicament;

public class BaseMedicament {
	
	public static ArrayList<Medicament> liste_medicament(Base base) {
		ResultSet rs;
		Statement st;
		Medicament p;
		ArrayList<Medicament> tabMedoc = new ArrayList<Medicament>();
		try {
			st = (Statement) base.getConnection().createStatement();
			rs = (ResultSet) st.executeQuery("Select * from medicament");
			
			while(rs.next()) {
				p = new Medicament();
				p.setNom(rs.getString("nom"));
				p.setPosologie(rs.getString("posologie"));
				p.setComposant(rs.getString("composant"));
				p.setDescription(rs.getString("description"));
				tabMedoc.add(p);
				System.out.println(rs.getString("nom"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return tabMedoc;
	}

}